package com.iscreen.utils.xml;

import java.io.File;

import javax.xml.XMLConstants;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;

import org.xml.sax.SAXException;

import com.iscreen.utils.exceptions.IScreenException;
import com.iscreen.utils.exceptions.IScreenExceptionCodes;

public final class XMLUtils
{
	public static Schema getSchema(String schemaFileName) throws IScreenException
	{
		File schemaFile = new File(schemaFileName);
		SchemaFactory sf =
		    SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI );
		try {
		    return sf.newSchema( schemaFile );
		} catch( SAXException e ){

		    throw new IScreenException(IScreenExceptionCodes.XML_SCHEMA_PARSE_ERROR,e);
		}
		
	}

}
